<template>
  <div id="SsoInnerSite">
    <template v-if="formData.state==='2'">
      <iframe style="width: 100%;min-height: 720px;" :src="iframeSrc"></iframe>
    </template>
    <template v-if="formData.state!='2'">
      <h3 style="padding-left: 50px;padding-top: 30px;">已在外部打开应用</h3>
    </template>
  </div>
</template>

<script>
import { requestGet } from '../../../utils/request'
import API_KEY from '../../../api'

export default {
  name: 'SsoInnerSite',
  data () {
    return {
      iframeSrc: '',
      menuCode: 'system-SsoInnerSite',
      formData: {
        ssoAppId: '',
        state: '2'
      }
    }
  },
  created () {
    this.formData.ssoAppId = this.$route.query.ssoAppId
    const ssoAppId = this.$route.query.ssoAppId
    if (this.$route.query.state != null) {
      this.formData.state = this.$route.query.state
    }
    if (ssoAppId != null) {
      requestGet(API_KEY.dcSso.getSsoTempAuthCode, this.formData).then(({ data }) => {
        if (this.formData.state === '2') {
          this.iframeSrc = data
        } else {
          window.open(data)
        }
      })
    }
  }
}
</script>

<style scoped>

</style>
